package com.qfjy.controller;


import com.qfjy.common.util.result.ResultCode;
import com.qfjy.common.util.result.ResultJson;
import com.qfjy.entity.po.Demo;
import com.qfjy.service.DemoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping("demo")
@Slf4j
@Api(tags = {"案例模块"})
public class DemoController {

    @Autowired
    private DemoService demoService;

    @GetMapping("list")
    @ResponseBody
    @ApiOperation(value="查询所有的列表数据")
    public Object list(){

        List<Demo> list=demoService.selectList();

        if(list.size()==0){
            return new ResultJson<>(null, ResultCode.NOT_DATA);
        }
        return new ResultJson<>(list,ResultCode.SUCCESS) ;
    }
}
